package com.kuang.proxy;


//真实对象和代理对象都要实现同一个接口
//代理对象要代理真实角色
//
//代理对象可以做很多真实对象做不了的事情
//真实对象专注做自己的事

public class StaticProxy {
    public static void main(String[] args) {
        You you=new You();
        WeddingProxy weddingProxy = new WeddingProxy(you);
        weddingProxy.HappyMarry();
    }
}
interface Marry {
    void HappyMarry();
}
//真实角色
class You implements Marry {
    public void HappyMarry() {
        System.out.println("你结婚了");
    }
}
//代理角色
class WeddingProxy implements Marry {
    //代理目标对象
    private Marry client;
    public WeddingProxy(Marry client) {
        this.client = client;
    }
    public void HappyMarry() {
        before();
        this.client.HappyMarry(); //这是真实对象
        after();
    }
    private void after() {
        System.out.println("结婚之后收拾会场");
    }
    private void before() {
        System.out.println("结婚之前布置会场");
    }
}

